/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.facades.factories;

import com.sdd.entities.Feature;
import com.sdd.plains.FeaturePlain;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 *
 * @author T
 */
@Stateless
@LocalBean
public class FeatureFactoryFacadeBean {

    @EJB
    private FeatureCategoryFactoryFacadeBean fcfb;

    public FeaturePlain createFeaturePlain(Feature entity) {
        if (entity==null)
            return null;
        FeaturePlain ret = new FeaturePlain();
        ret.setId(entity.getId());
        ret.setSummary(entity.getSummary());
        ret.setDescription(entity.getDescription());
        ret.setCategory(fcfb.createFeatureCategoryPlain(entity.getCategory()));
        return ret;
    }

    public Feature createFeature(FeaturePlain fp) {
        if (fp==null)
            return null;
        Feature f = new Feature();
        f.setId(fp.getId());
        f.setSummary(fp.getSummary());
        f.setDescription(fp.getDescription());
        return f;
    }

    public List<FeaturePlain> createFeaturesPlains(List<Feature> entities) {
        if (entities != null) {
            List<FeaturePlain> ret = new ArrayList<FeaturePlain>();
            for (Feature feature : entities) {
                ret.add(createFeaturePlain(feature));
            }
            return ret;
        } else {
            
            return null;
        }

    }

    public List<Feature> createFeatures(List<FeaturePlain> fps) {
        if (fps==null)
            return null;
        List<Feature> ret = new ArrayList<Feature>();
        for (FeaturePlain fp : fps) {
            ret.add(createFeature(fp));
        }
        return ret;
    }
}
